﻿using System;
using System.Drawing;
using AudioPlayer.Database;
using AudioPlayer.Plugin;
using AudioPlayer.Plugin.Playback;
using AudioPlayer.Plugin.Storage;
using AudioPlayer.Storage;
namespace AudioPlayer {
	internal static class Config {
		#region Variables
		private static Library _library;
		private static Images _images;
		private static PluginLoader _pluginContainer;
		private static Settings _settings;
		#endregion
		#region Constructor
		
		#endregion
		#region Static Voids
		public static void Init() {
			_pluginContainer = new PluginLoader();
			
			//Default plugins
			_pluginContainer.Plugins.Add(new PluginBase(new DefaultWatcher()));
			_pluginContainer.Plugins.Add(new PluginBase(new PlayControl()));
			//
			_pluginContainer.Search(System.Windows.Forms.Application.StartupPath + "\\Plugin\\");
			_pluginContainer.ReadConfig();
			_pluginContainer.LoadDefault();
			AudioPlayer.GUI.Theme.ThemeManager.CreateDefault();
		}
		#endregion
		#region Property
		public static Library Library {
			get {
				if (_library == null) {
					_library = new Library();
				}
				return _library;
			}
			set { _library = value; }
		}
		public static Images Images {
			get {
				if (_images == null) {
					_images = new Images();
				}
				return _images;
			}
		}
		public static PluginLoader Plugins {
			get {
				if (_pluginContainer == null) {
					_pluginContainer = new PluginLoader();
				}
				return _pluginContainer;
			}
		}
		public static Settings Settings {
			get {
				if (_settings == null) {
					_settings = new Settings();
				}
				return _settings;
			}
		}
		#endregion
	}
	/// <summary>
	/// Hold Application wide settings
	/// </summary>
	internal class Settings {
		#region Fields
		private IUserSettings _cache;
		#endregion
		#region Constructor
		public Settings() {
			//TODO: Find better way to use assembly info guid.
			_cache = new UserSettings(new Guid("ffd715a4-cfe6-490a-8a80-a531426b75a3"));
		}
		#endregion
		#region Property
		/// <summary>
		/// Gets or sets a value indicating whether show effects.
		/// Default: false
		/// </summary>
		/// <value><c>true</c> if shows effects; otherwise, <c>false</c>.</value>
		public bool ShowEffects {
			get {
				return _cache.Get<bool>("ShowEffects");
			}
			set {
				_cache.Set<bool>("ShowEffects", value);
			}
		}

		/// <summary>
		/// Gets the cache.
		/// </summary>
		/// <value>The cache.</value>
		public IUserSettings Cache {
			get { return _cache; }
		}
		#endregion
	}
	internal class Images {

		#region Property
		public Bitmap StarFull {
			get { return Properties.Resources.starFull; }
		}
		public Bitmap StartHalf {
			get { return Properties.Resources.starHalf; }
		}
		public Bitmap StarBlank {
			get { return Properties.Resources.starBlank; }
		}
		#endregion
		#region Player
		public Bitmap PlayerStart {
			get {
				return Properties.Resources.PlayerStart;
			}
		}
		public Bitmap PlayerStop {
			get { return Properties.Resources.PlayerStop; }
		}
		public Bitmap PlayerPlay {
			get { return Properties.Resources.PlayerPlay; }
		}
		public Bitmap PlayerPause {
			get { return Properties.Resources.PlayerPause; }
		}
		public Bitmap PlayerEnd {
			get { return Properties.Resources.PlayerEnd; }
		}
		public Bitmap PlayerRec {
			get { return Properties.Resources.PlayerRec; }
		}
		public Bitmap PlayerRew {
			get { return Properties.Resources.PlayerRew; }
		}
		public Bitmap PlayerFwd {
			get { return Properties.Resources.PlayerFwd; }
		}
		#endregion
	}
}
